#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std
int main(){
    vector<int> b;
    int i;
    for (i = 2; i < 1000; i++) {
        int a = 1;
        for (int j = 2; j < i / 2; j++) {
            if (i % j == 0) {
                a = 0;
                break;
            } 
            if (a) {
                b.push_back(i);
            }
        }
    }
    string n[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    string c;
    c = input().replace('9', '&').replace('8', '&').replace('7', '&').replace('6', '&')
        .replace('5', '&').replace('4', '&').replace('3', '&').replace('2', '&')
        .replace('1', '&').replace('0', '&');
    if ((string::size_type)c.find_first_of("&") != string::npos || (string::size_type)c.length() != 3) {
        cout << "Wrong input" << endl;
    } else {
        vector<string> d = c.split("");
        string w;
        for (auto i : d) {
            w += to_string(n->find(i));
        }
        int k = stoi(w);
        vector<pair<int, int>> s;
        for (auto i : b) {
            s.push_back({abs(k - i), i});
        }
        sort(s.begin(), s.end());
        cout << s[0].second << endl;
    }
    return 0;
}

